home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13769 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: news2.cais.com!news
  2. From: Nehal Trivedi <ntrivedi@cais.com>
  3. Newsgroups: comp.object,comp.lang.c++
  4. Subject: Re: Defining Object Associations
  5. Date: Wed, 27 Mar 1996 00:33:57 -0500
  6. Organization: Instant Karma
  7. Message-ID: <3158D345.12A4@cais.com>
  8. References: <4j9ens$jtq@crchh327.rich.bnr.ca>
  9. NNTP-Posting-Host: ntrivedi.cais.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Bret Bieghler wrote:
  16. > Are there any preferences to defining object associations in
  17. > C++.  My working system has several objects that must all
  18. > communicate with each other, and many objects have to be in
  19. > existence before creating another certain type.
  20. > ......
  21. > Thanks for any suggestions you may have.
  22. > Regards,
  23. > Joseph A. Bell
  24. > Nortel Technologies
  25.  
  26. I believe that you should take another look at your class hierarchy - do some 
  27. OOAD. There are several things that come to mind when I read your description of 
  28. the problem:
  29. - How big is this group of inter-related classes?
  30. - What is their life-cycle? Who is responsible for creating and deleting them?
  31. - What are the usage dependencies?
  32. and so on.
  33. The best way to decide is to do some OOAD first. Then draw some instance diagrams 
  34. and some object interaction diagrams and see what the picture looks like. Setting 
  35. all relationships in the constructor can cause a dependency management headache. 
  36. There are design patterns such as object factories that can be useful. I would 
  37. urge you to use global collections of references/pointers and stuff like that 
  38. only as a last resort, especially if you are planning on using DLLs or threads.
  39.  
  40. Thanks
  41. Nehal Trivedi
  42.